package com.proxy.parser.visitor;

import com.alibaba.druid.sql.ast.statement.SQLUseStatement;
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor;
import com.proxy.parser.ParsedResult;
import com.proxy.parser.result.UseParsedResult;
import com.proxy.parser.PoxyVisitor;

/**
 * Created by liufish on 16/12/27.
 */
public class UseVisitor extends MySqlSchemaStatVisitor implements PoxyVisitor {

    private UseParsedResult useParsedResult;

    public UseVisitor(ParsedResult parsedResult){

        this.useParsedResult = (UseParsedResult)parsedResult;
    }


    @Override
    public boolean visit(SQLUseStatement x) {
        boolean superValue = super.visit(x);
        return superValue;
    }

    @Override
    public void endVisit(SQLUseStatement x) {
       this.useParsedResult.setDataBase( x.getDatabase().getSimpleName());

    }


}
